<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        // let set = new Set([1,2,3,4]);
        // let it = set[Symbol.iterator]();
        // console.log(it.next());
        // console.log(it.next());
        // console.log(it.next());
        // console.log(it.next());
        // console.log(it.next());
        // for(item of it){
        //     console.log(item)
        // }

        let obj = {
            name:"张三",
            age:18,
            gender:"男",
            [Symbol.iterator] : function(){
            let val = Object.values(obj);
            let idx = -1;
            return{
                next:function(){
                    idx++;
                    if(idx<val.length){
                        return{done:false,value:val[idx]};
                    }
                    else{
                        return{done:true,value:val[idx]}
                    }
                }
            }
           
        },
         say:function(){
            console.log("haha")
        }
        
        };
        // obj[Symbol.iterator] = function(){
        //     let val = Object.values(obj);
        //     let idx = -1;
        //     return{
        //         next:function(){
        //             idx++;
        //             if(idx<val.length){
        //                 return{done:false,value:val[idx]};
        //             }
        //             else{
        //                 return{done:true,value:val[idx]}
        //             }
        //         }
        //     }
        // }
        let it = obj[Symbol.iterator]();
         objsay();
        console.log(it.next()) 
        console.log(it.next()) 
        console.log(it.next()) 
        console.log(it.next()) 
    </script>
    
</body>
</html>